package top.majuan.lianxi.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.majuan.lianxi.base.PageBean;
import top.majuan.lianxi.base.R;
import top.majuan.lianxi.entity.TbCpu;
import top.majuan.lianxi.service.TbCpuService;
import top.majuan.lianxi.vo.PageVo;

@RestController
@RequestMapping("/cpu")
@RequiredArgsConstructor
public class TbCpuController {
    public final TbCpuService tbCpuService;

    @PostMapping
    public R<String> insert(@RequestBody TbCpu tbCpu) {
        return tbCpuService.insert(tbCpu);
    }

    @PutMapping ("")
    public R<String> update(@RequestBody TbCpu tbClass) {
        return tbCpuService.update(tbClass);
    }

    @GetMapping("/{id}")
    public R<TbCpu> queryByid(@PathVariable("id") Integer id) {
        return tbCpuService.queryByid(id);
    }

    @DeleteMapping("/{id}")
    public R<String> delete(@PathVariable("id") Integer id) {
        return tbCpuService.delete(id);
    }

    @GetMapping ("/{pn}/{ps}")
    public R<PageVo<TbCpu>> queryPage(@PathVariable("pn") Long pageNumber,@PathVariable("ps") Long pageSize, TbCpu tbCpu) {

        return tbCpuService.queryPage(PageBean.instance(pageNumber, pageSize), tbCpu);
    }
}